package com.huanzhidadi.java8inaction.chapter7.observer;


/**
 * Lambda表达式版的观察者模式
 */
public class LambdaClient {
    public static void main(String[] args) {
        Feed f = new Feed();
        f.registerObserver(msg -> {
            if (null!=msg && msg.contains("new land")) {
                System.out.println("Breaking news in NY! " + msg);
            }
        });
        f.registerObserver(msg -> {
            if (null!=msg && msg.contains("queen")) {
                System.out.println("Yet another news in Londen... " + msg);
            }
        });

        f.notifyObservers("They found new land!");
        
    }
}
